package com.atguigu.gamll_sugar.mapper;

import com.atguigu.gamll_sugar.entity.VisitorStats;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author chenlongStart
 * @create 2021-07-07 19:51
 * @desc
 */
public interface VisitorStatsMapper {

    @Select("SELECT \n" +
            "    toHour(stt) AS hour,\n" +
            "    sum(pv_ct) AS pv,\n" +
            "    sum(uv_ct) AS uv,\n" +
            "    sum(uj_ct) AS uj,\n" +
            "    sum(sv_ct) AS sv\n" +
            "FROM visitor_stats_2021\n" +
            "WHERE toYYYYMMDD(stt) = #{date}\n" +
            "GROUP BY toHour(stt)")
    List<VisitorStats> getVisitorGMV(@Param("date") int date);


    @Select("SELECT\n" +
            "    is_new AS is_new,\n" +
            "    sum(pv_ct) AS pv,\n" +
            "    sum(uv_ct) AS uv,\n" +
            "    sum(uj_ct) AS uj,\n" +
            "    sum(sv_ct) AS sv\n" +
            "FROM visitor_stats_2021\n" +
            "WHERE toYYYYMMDD(stt) = #{date}\n" +
            "GROUP BY is_new\n")
    List<VisitorStats> statsByIsNew(int date);
}
